-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
PERF: fix SparseArray._simple_new object initialization #32821
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PERF: fix SparseArray._simple_new object initialization #32821
Conversation
Thanks @jorisvandenbossche! Quick benchmark result below when running
so overall this makes that method around 30% faster. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @jorisvandenbossche lgtm
@rth thanks for the timings! Yes, it was indeed a large part of the original slow |
so we have asvs for this? also add a whats new note |
Note added in #32825 that should work for both PRs I think. |
Apart from this being more idiomatic, it also avoids creating a SparseArray through the normal machinery (including validation of the input etc) for the empty list.
With this PR:
while on released version this gives around 50µs (100x slower)
Noticed while investigating #32196